//
//  RegisterViewController.m
//  LoverGo
//
//  Created by YeXiao on 14-1-18.
//  Copyright (c) 2014年 yexiao. All rights reserved.
//

#import "DataCenter.h"
#import "RegisterViewController.h"
#import "MobClick.h"
@interface RegisterViewController ()

@end

@implementation RegisterViewController

-(id)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
-(void)loadView
{
    [self dinglan];
    _rView = [[RegisterView alloc] initWithFrame:CGRectMake(0, STATUSBAR +TOPBAR, SCREEN_WIDTH, SCREEN_HEIGHT - (STATUSBAR +TOPBAR))];
    _rView.delegate = self;
    
    [self setView:_rView];
}
-(void)dinglan{
    UIButton * backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0,20, 20)];
    [backBtn setBackgroundImage:[UIImage imageNamed:@"btn_back.png"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(dinglanBackBtn) forControlEvents:UIControlEventTouchUpInside] ;
    [backBtn setShowsTouchWhenHighlighted:YES] ;
    UIBarButtonItem *backbutton = [[UIBarButtonItem alloc]initWithCustomView:backBtn];
    self.navigationItem.leftBarButtonItem = backbutton;
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(90, 0, 140, 30)];
    title.textAlignment = UITextAlignmentCenter;
    title.textColor = LGCOLOR_blue;
    title.text = @"商家";
    self.navigationItem.titleView = title;
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"barBG.png"] forBarMetrics:UIBarMetricsDefault];
}
-(void)dinglanBackBtn{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad
{
    [super viewDidLoad];

	// Do any additional setup after loading the view.
}
-(void)viewDidUnload
{
    
}

-(void)RegisterView:(RegisterView *)view withType:(RegisterType)type
{
    if (type == RegisterTypeSub) {
        //注册
        NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
        [dic setValue:[view.nameTF text] forKey:@"appUser.userName"];
        [dic setValue:[view.passwordTF text] forKey:@"appUser.password"];
        [dic setValue:[[DataCenter getSingleton] getPlatform] forKey:@"appUser.mobile"];
        
        if ([[view.emailTF text] compare:@""] != 0) {
            [dic setValue:[view.emailTF text] forKey:@"appUser.email"];
        }
    }
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"注册"];
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"注册"];
}
@end
